using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class WeaponExplorer : Panel
{
    public WeaponExplorerList m_ExplorerList;
    public WeaponDesigner m_WeaponDesigner;
    public Dropdown m_WhatTypeOfWeaponBeCreate;
    public Dropdown m_WhatLevelOfWeaponBeCreate;

    private void Awake()
    {
        m_ExplorerList.m_OnWeaponSelectedCallback = OnShipBeOpendByBlueprint;
    }
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public override void Hide()
    {
        gameObject.SetActive(false);
    }
    public override void Show()
    {
        gameObject.SetActive(true);
        m_ExplorerList.Init();
    }
    public void OnShipBeOpendByBlueprint(Weapon weapon)
    {
        m_WeaponDesigner.Init(weapon);
        Hide();
        m_WeaponDesigner.Show();
        m_WeaponDesigner.m_PreviousPanel = this;
    }

    public void OnRefreshClicked()
    {
        m_ExplorerList.Init();
    }
    public void OnCreateNewClicked()
    {
        Weapon newWeapon = null;
        switch(m_WhatTypeOfWeaponBeCreate.value)
        {
            case 0:
                newWeapon = ItemManager.Instance.createItem(Item.ItemType.ARTILLARY.ToString()) as Weapon;
                break;
            case 1:
                newWeapon = ItemManager.Instance.createItem(Item.ItemType.LASER.ToString()) as Weapon;
                break;
            case 2:
                newWeapon = ItemManager.Instance.createItem(Item.ItemType.RAILGUN.ToString()) as Weapon;
                break;
            case 3:
                newWeapon = ItemManager.Instance.createItem(Item.ItemType.ROCKET.ToString()) as Weapon;
                break;
        }
        newWeapon.m_Level = (Weapon.Level)m_WhatLevelOfWeaponBeCreate.value;
        newWeapon.Clear();
        m_WeaponDesigner.Init(newWeapon);
        Hide();
        m_WeaponDesigner.Show();
        m_WeaponDesigner.m_PreviousPanel = this;
    }
}
